﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

namespace DataShow.codeDAL
{
    public class ForecasterProcess
    {
        #region 构造函数

        SqlHelper sqlhelper;
        public ForecasterProcess()
        {
            sqlhelper = new SqlHelper();
        } 
        #endregion

        #region 添加一条预报员记录
        /// <summary>
        /// 添加一条预报员记录
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool AddItem(codeModel.UserAddData data)
        {
            string sql = "insert into " + data.TableName + " values(@date,@clock,@span,@sendpoint,@type,@semitype,@value,@semi)";
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@date",data.Date),
                new SqlParameter("@clock",data.Clock),
                new SqlParameter("@span",data.Span),
                new SqlParameter("@sendpoint",data.SendPoint),
                new SqlParameter("@type",data.Type),
                new SqlParameter("@semitype",data.Semitype),
                new SqlParameter("@value",data.Value),
                new SqlParameter("@semi","")
            };
            return sqlhelper.ExecuteNonQuery(sql, param) > 0;
        } 
        #endregion

        #region 获得所有预报员
        /// <summary>
        /// 获得所有预报员
        /// </summary>
        /// <returns></returns>
        public DataTable ReadAllForecasters()
        {
            string sql = "select username,name from account_forecaster where is_forcaster=1";
            return sqlhelper.ExecuteQuery(sql, CommandType.Text);
        } 
        #endregion
    }
}